package com;

import java.net.InetAddress;

public class TestIP {
public static void main(String[] args) throws Exception {
	 InetAddress address = InetAddress.getLocalHost();
     System.out.println(address.getHostName());//主机名
     System.out.println(address.getCanonicalHostName());//主机别名
     System.out.println(address.getHostAddress());//获取IP地址
     System.out.println("===============");
}
}
